import { Log } from "@/data/entity/Log";
import { JobName, TIME_SETTING } from "@/data/constants/Constants";

export class Settings{
    defaultLogSetting:Log = new Log()
    logSetting:LogSetting = new LogSetting()
    excelKeySetting:ExcelKeySetting = new ExcelKeySetting()
    logFormatSetting:LogFormatSetting = new LogFormatSetting()
    static parse(object:any):Settings{
        if (typeof object != 'object' || !object){
            object = {}
        }

        object.defaultLogSetting = Log.parse(object.defaultLogSetting)
        object.logSetting = LogSetting.parse(object.logSetting)
        object.excelKeySetting = ExcelKeySetting.parse(object.excelKeySetting)
        object.logFormatSetting = LogFormatSetting.parse(object.logFormatSetting)
        return {...new Settings(), ...object}
    }
}

export class LogSetting{
    date: string = TIME_SETTING.THIS_HOUR
    static parse(object:any):LogSetting{
        return {...new LogSetting(), ...object}
    }
}

export class ExcelKeySetting{
    count:string = '完成场次'
    duty:string = '副本' // 副本
    job:string = '职业' // 职业
    completed:string = '是否完成' // 完成情况
    description:string = '描述'// 描述
    image:string = '图片'
    date:string = '日期' // 日期
    time:string = '时间'
    static parse(object:any):ExcelKeySetting{
        return {...new ExcelKeySetting(), ...object}
    }
}

export class LogFormatSetting{
    jobMap:[[number,string]] = JobName
    completed:string= '完成'
    static parse(object:any):LogFormatSetting{
        return {...new LogFormatSetting(), ...object}
    }
}
